package com.glsx.auto;

import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.body.ClassOrInterfaceDeclaration;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.visitor.VoidVisitorAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by linxy on 2017/4/21.
 */
public class DocVoidVisitorAdapter extends VoidVisitorAdapter<Void> {
    private CompilationUnit cu;
    private ClassOrInterfaceDeclaration classOrInterfaceDeclaration;
    List<MethodDeclaration> methodDeclarations = new ArrayList<MethodDeclaration>();

    public DocVoidVisitorAdapter(CompilationUnit cu) {
        this.cu = cu;
        visit(cu, null);
    }

    @Override
    public void visit(ClassOrInterfaceDeclaration n, Void doc) {
        super.visit(n, doc);
        classOrInterfaceDeclaration = n;
    }

    @Override
    public void visit(MethodDeclaration n, Void doc) {
        super.visit(n, doc);
        methodDeclarations.add(n);
    }

    public CompilationUnit getCu() {
        return cu;
    }

    public ClassOrInterfaceDeclaration getClassOrInterfaceDeclaration() {
        return classOrInterfaceDeclaration;
    }

    public void setClassOrInterfaceDeclaration(ClassOrInterfaceDeclaration classOrInterfaceDeclaration) {
        this.classOrInterfaceDeclaration = classOrInterfaceDeclaration;
    }

    public List<MethodDeclaration> getMethodDeclarations() {
        return methodDeclarations;
    }

    public void setMethodDeclarations(List<MethodDeclaration> methodDeclarations) {
        this.methodDeclarations = methodDeclarations;
    }
}
